Return to start page
Systems/Character/Struct Class.j
1 /// Why should it be contained by ACharacter?
2 library AStructSystemsCharacterClass
3
4 struct AClass
5 //static constant members
6 public static constant integer maxAbilities = 12 //For class selection
7 public static constant integer maxDescriptionLines = 8 //For class selection
8 //static start members
9 private static integer m_startLevel
10 private static integer m_startSkillPoints
11 //dynamic members
12 private string array m_abilityIconPath[thistype.maxAbilities] //for character class selection
13 private integer array m_ability[thistype.maxAbilities] //for character class selection
14 private string array m_descriptionLine[thistype.maxDescriptionLines] //for character class selection
15 //start members
16 private integer m_unitType
17 private string m_animation
18 private string m_soundPath
19
20 //dynamic members
21
22 public method setAbilityIconPath takes integer number, string abilityIconPath returns nothing
23 set this.m_abilityIconPath[number] = abilityIconPath
24 endmethod
25
26 public method abilityIconPath takes integer number returns string
27 return this.m_abilityIconPath[number]
28 endmethod
29
30 public method setAbility takes integer number, integer usedAbility returns nothing
31 set this.m_ability[number] = usedAbility
32 endmethod
33
34 public method ability takes integer number returns integer
35 return this.m_ability[number]
36 endmethod
37
38 public method setDescriptionLine takes integer number, string descriptionLine returns nothing
39 set this.m_descriptionLine[number] = descriptionLine
40 endmethod
41
42 public method descriptionLine takes integer number returns string
43 return this.m_descriptionLine[number]
44 endmethod
45
46 //start members
47
48 /// Friend relation to AClassSelection, don't use.
49 public method unitType takes nothing returns integer
50 return this.m_unitType
51 endmethod
52
53 /// Friend relation to AClassSelection, don't use.
54 public method animation takes nothing returns string
55 return this.m_animation
56 endmethod
57
58 /// Friend relation to AClassSelection, don't use.
59 public method soundPath takes nothing returns string
60 return this.m_soundPath
61 endmethod
62
63 //methods
64
65 public method containsAbility takes integer usedAbility returns boolean
66 local integer i = 0
67 loop
68 exitwhen (i == thistype.maxAbilities)
69 if (this.m_ability[i] == usedAbility) then
70 return true
71 endif
72 set i = i + 1
73 endloop
74 return false
75 endmethod
76
77 public method generateUnit takes player user, real x, real y, real facing returns unit
78 local unit usedUnit = CreateUnit(user, this.m_unitType, x, y, facing)
79 call SetHeroLevelBJ(usedUnit, thistype.m_startLevel, false)
80 call UnitModifySkillPoints(usedUnit, (thistype.m_startSkillPoints - GetHeroSkillPoints(usedUnit))) //Setzt die Fähigkeiten-Punkte
81 return usedUnit
82 endmethod
83
84 /// @param unitType Should be the type of a hero
85 public static method create takes integer unitType, string animation, string soundPath returns thistype
86 local thistype this = thistype.allocate()
87 //start members
88 set this.m_unitType = unitType
89 set this.m_animation = animation
90 set this.m_soundPath = soundPath
91
92 return this
93 endmethod
94
95 public static method init takes integer startLevel, integer startSkillPoints returns nothing
96 //static start members
97 set thistype.m_startLevel = startLevel
98 set thistype.m_startSkillPoints = startSkillPoints
99 endmethod
100 endstruct
101
102 endlibrary